using System.Diagnostics;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ApprovalTests.Reporters;
using System;
using SmallBasicFun.Tracking;

namespace SmallBasicFun.Tests
{
	[TestClass]
	[UseReporter(typeof(DiffReporter))]
	public class ProgramWindowTest
	{

		public bool SmallBasicRunning
		{
			get
			{
				return  ProcessUtil.GetSmallBasicProcess() != null;

			}
		}

		
		[TestMethod]
		public void TestProcess()
		{
			  Assert.AreEqual(ProcessUtil.GetSmallBasicProcess() != null, SmallBasicRunning);
		}

		[TestMethod]
		public void TestGetLocationOfSmallBasicWithoutException()
		{
			Debug.WriteLine(ScreenCapture.GetProctorInfoFileLocation());

			if (SmallBasicRunning)
			{
				var path = ScreenCapture.GetProctorInfoFileLocation();
				Assert.IsTrue(path.Contains("proctor.txt"), path);
				Assert.IsTrue(File.Exists(path));
			}
			else
			{
				Assert.IsNull(ScreenCapture.GetProctorInfoFileLocation());
			}
		}

		[TestMethod]
		public void TestConcatentateDisplayScreenShotLocation()
		{
			var fileNameResult                              = ScreenCapture.GetProctorFileName();
			var locationOfSmallBasicResult                  = ScreenCapture.GetProctorInfoFileLocation();
			var concatentatedResultWithDisplayFormatting    = String.Format("Location = {0}\r\nProctor.txt = {1} ", fileNameResult, locationOfSmallBasicResult);

			Assert.AreEqual(concatentatedResultWithDisplayFormatting, ScreenCapture.ConcatentateDisplayScreenShotLocation());
		}

		[TestMethod]
		public void TestGetWindoNotNull()
		{
			var window = ProgramWindow.GetWindow();

			Assert.IsNotNull(window);
		}

		
		[TestMethod]
		public void TestGetFileName()
		{
			Debug.WriteLine(ScreenCapture.GetProctorFileName());
		}
	}
}